﻿namespace Devonline.Entity;

/// <summary>
/// 包装
/// </summary>
[Table("package"), DisplayName("包装")]
public class Package : Package<string>, IEntitySet, IEntitySetWithCreate
{
    /// <summary>
    /// 通用附件集合, NotMapped Attachments 用于记录实体对象上上传的附件
    /// </summary>
    [NotMapped]
    public virtual ICollection<Attachment>? Attachments { get; set; }
}

/// <summary>
/// 包装
/// </summary>
[Table("package"), DisplayName("包装")]
public abstract class Package<TKey> : EntitySetWithCreate<TKey>, IEntitySet<TKey>, IEntitySetWithCreate<TKey> where TKey : IConvertible
{
    /// <summary>
    /// 名称
    /// </summary>
    [Column("name"), Required, MaxLength(128), DisplayName("名称"), Excel]
    public virtual string Name { get; set; } = null!;
    /// <summary>
    /// 封面图
    /// </summary>
    [Column("image"), MaxLength(128), DisplayName("封面图"), BusinessType(IsAttachment = true), Excel]
    public virtual string? Image { get; set; }
    /// <summary>
    /// 包装单位, 包装单位
    /// </summary>
    [Column("unit", TypeName = "varchar(16)"), DisplayName("包装单位"), DefaultValue(PackageUnit.BOX), Excel]
    public virtual PackageUnit Unit { get; set; }
    /// <summary>
    /// 货品类型
    /// </summary>
    [Column("type", TypeName = "varchar(16)"), DisplayName("包装方式"), DefaultValue(PackageType.Box), Excel]
    public virtual PackageType Type { get; set; }
    /// <summary>
    /// 外观尺寸, 装箱规格, 装箱尺寸, 长宽高[+公差]+单位
    /// 表述形式: 长*宽*高[±公差]单位, 可以带单位, 也可以不带单位, 单位可以是 mm, cm, inch 等等, 也可以是 m, ft 等等, 也可以是个数等单位
    /// 如: 25*35*10±1 mm
    /// </summary>
    [Column("size"), MaxLength(128), DisplayName("尺寸"), Excel]
    public virtual string Size { get; set; } = null!;
    /// <summary>
    /// 包装本身单价, 用于计算销售成本
    /// </summary>
    [Column("price", TypeName = "decimal(18,2)"), DisplayName("单价"), Excel]
    public virtual decimal Price { get; set; }
}